<?php
namespace Admin\Controller;

use Think\Controller;

class VoucherController extends CommenController
{
    /**
     * 商户借条列表
     */
    public function merchant_debit_list()
    {
        $certificate_db = M('certificate', '', 'XYC');
        $certificate_alipay_db=M('certificate_alipay','','XYC');
        $time = !empty(I('time_type')) ? I('time_type') : 'ctime';
        $where = MycommonController::set_where(array('status'), array('numbering','borrower', 'card_id', 'lender', 'mobile'), $time);
        $where['shop_identifier'] = $_SESSION['shop_identifier'];
        $where['is_delete'] = '1';
        if(empty(I('status'))){
            $where['status'] = ['neq','1'];
        }
        if(in_array('3',explode(',',$_SESSION['rid'])) && !in_array('1',explode(',',$_SESSION['rid']))){
            $user_list=M('user_login','','XYC')->WHERE(['collector'=>$_SESSION['id']])->getField('user_id',true);
            $where['borrower_id']=['in',$user_list];
        }
//        var_dump($where);
        $tol = $certificate_db->WHERE($where)->COUNT();
        $row = '10';
        $page = new PageController($tol, $row);
        $fpage = $page->fpage();
        $list = $certificate_db->WHERE($where)->FIELD("id")->LIMIT($page->listfirst, $page->listRows)->ORDER("id desc")->SELECT();
        $list = array_column($list, 'id');
        $list = $certificate_db->WHERE(['id' => ['in', $list]])->ORDER("id desc")->SELECT();

        foreach ($list as $k => $v) {
            $list[$k]['loan_time'] = date('Y-m-d', $v['loan_time']);
            $list[$k]['repayment_time'] = date('Y-m-d', $v['repayment_time']);
            $list[$k]['tear_time'] = !empty($v['tear_time']) ? date('Y-m-d', $v['tear_time']) : '';
            if($_SESSION['is_hide']=='2'){
                $list[$k]['mobile'] = set_privacy($v['mobile'],'1');
            }
            $check_pay=$certificate_alipay_db->WHERE(['shop_identifier'=>$_SESSION['shop_identifier'],'certificate_no'=>$v['numbering'],'status'=>['in',['3','7','8']]])->getField('id');
            $list[$k]['check_pay']='1';//未支付
            if(!empty($check_pay)){
                $list[$k]['check_pay']='2';//已支付
            }
        }

        $this->assign(array(
            'list' => $list,
            'fpage' => $fpage,
            'tol' => $tol,
            'rate' => json_encode(range(0, 24))
        ));
        $this->display();
    }

    /**
     * 设置坏账
     */
    public function set_voucher_bad_debt()
    {
        if (!empty($_POST)) {
            $certificate_db = D('Certificate');
            $orderno = I('orderno');
            $res = $certificate_db->set_status($orderno,'5');
            if ($res === true) {
                add_control_log($_SESSION['shop_identifier'],$_SESSION['account'],"设置订单号【".$orderno."】为坏账",'3');
                MycommonController::ajax('1001', '操作成功');
            } else {
                MycommonController::ajax('1002', $res);
            }
        }
    }

    /**
     * 撕毁凭证
     */
    public function set_voucher_status()
    {
        if (!empty($_POST)) {
            $certificate_db = D('Certificate');
            $orderno = I('orderno');
            $res = $certificate_db->set_status($orderno, '6',I('real_repayment_money'),I('real_repayment_time'));
            if ($res === true) {
                $msg=$certificate_db->WHERE(['numbering'=>$orderno])->FIND();
                OftenController::tear_add_zzc($orderno);
                OftenController::external_confirm_voucher($msg);
                add_control_log($_SESSION['shop_identifier'],$_SESSION['account'],"撕毁订单号【".$orderno."】的凭证",'3');
                MycommonController::ajax('1001', '操作成功');
            } else {
                MycommonController::ajax('1002', $res);
            }
        }
    }

    /**
     * 删除凭证
     */
    public function del_voucher()
    {
        if (!empty($_POST)) {
            $certificate_db = D('Certificate');
            $orderno = I('orderno');
            $res = $certificate_db->del_certificate($orderno);
            if ($res === true) {
                add_control_log($_SESSION['shop_identifier'],$_SESSION['account'],"删除订单号【".$orderno."】的凭证",'3');
                MycommonController::ajax('1001', '操作成功');
            } else {
                MycommonController::ajax('1002', $res);
            }
        }
    }

    /**
     * 添加凭证
     */
    public function add_voucher()
    {
        if (!empty($_POST)) {
            $certificate_db = D('Certificate');
            $data['numbering'] = 'P' . build_orderno() . 'w';
            $data['initiate_id'] =$_SESSION['id'];
            $data['loan_time'] = strtotime(I('borrow_time'));
            $data['repayment_time'] = strtotime(I('repayment_time'));
            $data['period_time'] = strtotime(I('repayment_time'));
            $data['money'] = I('borrow_money');
            $data['actual_money'] =!empty(I('actual_money'))?I('actual_money'):I('borrow_money');
            $data['interest_rate'] = I('rate');
            $data['interest'] = get_rate_money(I('borrow_money'), I('rate'), ($data['repayment_time'] - $data['loan_time']) / (3600 * 24));
            $lender_msg = M('lender', '', 'XYC')->WHERE(['id' => I('lender'), 'shop_idenfier' => $_SESSION['shop_identifier'],'is_delete'=>'1'])->FIND();
            if (empty($lender_msg)) {
                MycommonController::ajax('1002', '出借人不存在');
            }
//            $data['loan_type'] = rand(1,5);
            $data['loan_type'] = 1;
            $data['lender'] = $lender_msg['name'];
            $data['lender_id'] = $lender_msg['id'];
            $data['lender_signature'] = $lender_msg['signature'];
            $param= I('borrow_mobile');
//            $borrow_user_msg = M('user', '', 'XYC')->WHERE(['mobile' => I('borrow_mobile'), 'shop_identifier' => $_SESSION['shop_identifier']])->FIND();
            $borrow_user_msg = M('user', '', 'XYC')->WHERE(['_string' =>"mobile='$param' or identity_num='$param'", 'shop_identifier' => $_SESSION['shop_identifier'],'is_delete'=>'1'])->FIND();
            if (empty($borrow_user_msg)) {
                MycommonController::ajax('1002', '借款人不存在');
            }
            $data['channel']=!empty($borrow_user_msg['channel'])?$borrow_user_msg['channel']:'';
            $data['card_id'] = $borrow_user_msg['identity_num'];
            $data['borrower'] = $borrow_user_msg['username'];
            $data['borrower_id'] = $borrow_user_msg['id'];
            $data['borrower_signature'] = M('user_sign_img', '', 'XYC')->WHERE(['user_id' => $borrow_user_msg['id']])->getField('sign_img');
            $data['borrower_signature']=!empty($data['borrower_signature'])?$data['borrower_signature']:'';
            $data['mobile'] = $borrow_user_msg['mobile'];
            $data['ctime'] = time();
            $data['shop_identifier'] = $_SESSION['shop_identifier'];
            $data['note'] = !empty(I('mark'))?I('mark'):'';
            $data['status']='1';
            $res = $certificate_db->create($data);
            if ($res) {
                $res = $certificate_db->add();
                if(!$res){
                    MycommonController::ajax('1002', '添加失败');
                }
                add_control_log($_SESSION['shop_identifier'],$_SESSION['account'],"添加凭证，订单号为【".$data['numbering'].'】','3');
                $receive_id=$data['borrower_id'];
                $numbering=$data['numbering'];
                $url='https://nxyc.dstlkj.com/Chatwith/certificate_api?receive_id='.$receive_id.'&numbering='.$numbering;
                MycommonController::set_curl($url);
                MycommonController::ajax('1001', '添加成功');
            } else {
                MycommonController::ajax('1002', $certificate_db->getError());
            }
        }
    }

    /**
     * 确认打款
     */
    public function play_money(){
        if(!empty($_POST)){
            $certificate_db=D('Certificate');
            $data['numbering']=I('orderno');
            if(empty(I('orderno'))){
                MycommonController::ajax('1002', '系统异常，请联系管理员');
            }
            $res=$certificate_db->check_play_money($data);
            if($res===true){
                add_control_log($_SESSION['shop_identifier'],$_SESSION['account'],"设置订单号【".$data['numbering'].'】打款成功','3');
                MycommonController::ajax('1001', '操作成功');
            } else {
                MycommonController::ajax('1002', $res);
            }
        }
    }

    /**
     * 添加打款记录
     */
    public function add_play_money_record(){
        if(!empty($_POST)){
            $certificate_db=D('Certificate');
            $data['actual_money']=I('actual_money');
            $data['pay_type']=I('pay_type');
            $data['money_certificate']=I('img_url');
            $data['numbering']=I('orderno');
            if(empty(I('orderno'))){
                MycommonController::ajax('1002', '系统异常，请联系管理员');
            }
            $res=$certificate_db->WHERE(['numbering'=>I('orderno'),'shop_identifier'=>$_SESSION['shop_identifier']])->SAVE($data);
            if($res!==false){
                add_control_log($_SESSION['shop_identifier'],$_SESSION['account'],"添加订单号【".$data['numbering'].'】打款记录','3');
                MycommonController::ajax('1001', '操作成功');
            } else {
                MycommonController::ajax('1002', $res);
            }
        }
    }

    /**
     * 添加续借信息
     */
    public function add_certificate_period(){
        if(!empty($_POST)){
            $certificate_period_db=D('CertificatePeriod');
            $data['numbering']=I('numbering');
            $data['repayment_time']=strtotime(I('repayment_time'));
            $data['period_time']=strtotime(I('period_time'));
            $data['period_days']=(strtotime(I('period_time'))-strtotime(I('repayment_time')))/(24*3600);
            $data['interest_rate']=I('rate');
            $data['interest']=I('fee');
            $data['shop_idenfier']=$_SESSION['shop_identifier'];
            $data['ctime']=time();
            $res=$certificate_period_db->create($data);
            if($res){
                $res=$certificate_period_db->add();
                if($res){
                    $borrow_id=D('Certificate')->where(['numbering'=>I('numbering')])->getField('borrow_id');
                    add_control_log($_SESSION['shop_identifier'],$_SESSION['account'],"订单号【".$data['numbering'].'】添加续借成功','3');
                    $receive_id=$borrow_id;
                    $numbering=$data['numbering'];
                    $url='https://nxyc.dstlkj.com/Chatwith/certificate_api?receive_id='.$receive_id.'&numbering='.$numbering;
                    MycommonController::set_curl($url);
                    MycommonController::ajax('1001', '操作成功');
                } else {
                    MycommonController::ajax('1002', '系统错误，请联系管理员');
                }
            }else{
                MycommonController::ajax('1002', $certificate_period_db->getError());
            }
        }
    }

    /**
     * 支付待支付凭证
     */
    public function pay_certificate(){
        if(!empty($_POST)){
            $certificate_db=D('Certificate');
            $numbering=I('numbering');
            $certificate_msg=$certificate_db->WHERE(['numbering'=>$numbering,'shop_identifier'=>$_SESSION['shop_identifier'],'status'=>'0'])->FIND();
            if(empty($certificate_msg)){
                MycommonController::ajax('1002','该订单不存在或者已支付');
            }
            $pay_data=[
                'shop_identifier'=>$_SESSION['shop_identifier'],
                'orderno'=>'P'.date('YmdHis').rand(1000,9999),
                'money'=>'8',
                'certificate_no'=>$numbering,
                'ctime'=>time()
            ];
            $res = M('certificate_alipay','','XYC')->add($pay_data);
            if($res){
                $res=$this->certificate_pay($pay_data['orderno']);
                MycommonController::ajax('1001',$res);
            }else{
                MycommonController::ajax('1002','系统错误，请联系管理员');
            }
        }
    }

    /**
     * 未确认凭证列表
     */
    public function merchant_debit_no_confirm_list()
    {
        $certificate_db = M('certificate', '', 'XYC');
        $time = !empty(I('time')) ? I('time') : 'ctime';
        $where = MycommonController::set_where(array('status'), array('borrower', 'card_id', 'lender', 'mobile'), $time);
        $where['shop_identifier'] = $_SESSION['shop_identifier'];
        $where['is_delete'] = '1';
        $where['status']='1';
        if(in_array('3',explode(',',$_SESSION['rid']))){
            $user_list=M('user_login','','XYC')->WHERE(['collector'=>$_SESSION['id']])->getField('user_id',true);
            $where['borrower_id']=['in',$user_list];
        }
        $tol = $certificate_db->WHERE($where)->COUNT();
        $row = '10';
        $page = new PageController($tol, $row);
        $fpage = $page->fpage();
        $list = $certificate_db->WHERE($where)->FIELD("id")->LIMIT($page->listfirst, $page->listRows)->ORDER("id desc")->SELECT();
        $list = array_column($list, 'id');
        $list = $certificate_db->WHERE(['id' => ['in', $list]])->ORDER("id desc")->SELECT();

        foreach ($list as $k => $v) {
            $list[$k]['loan_time'] = date('Y-m-d', $v['loan_time']);
            $list[$k]['repayment_time'] = date('Y-m-d', $v['repayment_time']);
            $list[$k]['tear_time'] = !empty($v['tear_time']) ? date('Y-m-d', $v['tear_time']) : '';
            if($_SESSION['is_hide']=='2'){
                $list[$k]['mobile'] = set_privacy($v['mobile'],'1');
            }
        }
        $this->assign(array(
            'list' => $list,
            'fpage' => $fpage,
            'tol' => $tol,
            'rate' => json_encode(range(0, 24))
        ));
        $this->display();
    }

    /**
     * 确认凭证
     */
    public function confirm_certificate(){
        if(!empty($_POST)){
            $certificate_db = D('Certificate');
            $data['numbering'] = I('numbering');
            $lender_msg = M('lender', '', 'XYC')->WHERE(['id' => I('lender'), 'shop_idenfier' => $_SESSION['shop_identifier'],'is_delete'=>'1'])->FIND();
            if (empty($lender_msg)) {
                MycommonController::ajax('1002', '出借人不存在');
            }
            $check_pay=M('certificate_alipay','','XYC')->WHERE(['shop_identifier'=>$_SESSION['shop_identifier'],'certificate_no'=>I('numbering'),'status'=>'3'])->getField('id');
            if(empty($check_pay) && I('numbering')!='P201808132013215611758w'){
                MycommonController::ajax('1002', '请先完成支付');
            }
            $certificate_msg=$certificate_db->WHERE(['shop_identifier'=>$_SESSION['shop_identifier'],'numbering'=>I('numbering')])->FIND();
            if(!empty($certificate_msg['status']!='1')){
                MycommonController::ajax('1002', '该凭证已确认，请刷新页面');
            }
            $data['lender'] = $lender_msg['name'];
            $data['lender_id'] = $lender_msg['id'];
            $data['lender_signature'] = $lender_msg['signature'];
            $data['status']='2';

            $res = $certificate_db->WHERE(['numbering'=>I('numbering'),'shop_identifier'=>$_SESSION['shop_identifier']])->SAVE($data);
            if ($res!==false) {
                $msg=$certificate_db->WHERE(['numbering'=>I('numbering')])->FIND();
                $msg['lender_idcard']=$lender_msg['idcard'];
                $msg['lender_mobile']=$lender_msg['mobile'];
                OftenController::zzc_up_data($data['numbering']);
                OftenController::external_confirm_voucher($msg);
                add_control_log($_SESSION['shop_identifier'],$_SESSION['account'],"确认凭证，订单号为【".$data['numbering'].'】','3');
                MycommonController::ajax('1001', '操作成功');
            } else {
                MycommonController::ajax('1002', '操作失败');
            }
        }
    }


    /**
     * 拒绝凭证
     */
    public function refuse_certificate(){
        if(!empty($_POST)){
            $certificate_db = D('Certificate');
            $orderno = I('numbering');
            $res = $certificate_db->set_status($orderno, '7');
            if ($res === true) {
                add_control_log($_SESSION['shop_identifier'],$_SESSION['account'],"拒绝订单号【".$orderno."】的凭证",'3');
                MycommonController::ajax('1001', '操作成功');
            } else {
                MycommonController::ajax('1002', $res);
            }
        }
    }

    /**
     * 出借人管理
     */
    public function lender_list()
    {
        $certificate_db = M('lender', '', 'XYC');
        $where = MycommonController::set_where(array(''), array('name', 'idcard','mobile'), '');
        $where['shop_idenfier'] = $_SESSION['shop_identifier'];
        $where['is_delete'] = '1';
        $tol = $certificate_db->WHERE($where)->COUNT();
        $row = '10';
        $page = new PageController($tol, $row);
        $fpage = $page->fpage();
        $list = $certificate_db->WHERE($where)->FIELD("id")->LIMIT($page->listfirst, $page->listRows)->ORDER("id desc")->SELECT();
        $list = array_column($list, 'id');
        $list = $certificate_db->WHERE(['id' => ['in', $list]])->ORDER("id desc")->SELECT();

        foreach ($list as $k => $v) {
            $list[$k]['ctime'] = date('Y-m-d H:i:s', $v['ctime']);
            if($_SESSION['is_hide']=='2'){
                $list[$k]['idcard'] = set_privacy($v['idcard'],'2');
            }
        }
        $this->assign(array(
            'list' => $list,
            'fpage' => $fpage,
            'tol' => $tol
        ));
        $this->display();
    }

    /**
     * 添加出借人
     */
    public function add_lender()
    {
        if (!empty($_POST)) {
            $lender_db = D('Lender');
            if(empty(I('signature'))){
                MycommonController::ajax('1002', '签名不能为空');
            }
            $file_name='./Public/'.time().rand(1000,9999).'.jpg';
            file_put_contents($file_name,base64_decode(str_replace('data:image/png;base64,','',I('signature'))));
            $res=MycommonController::addossimg($file_name);
            if($res===false){
                MycommonController::ajax('1002', '签名上传失败');
            }
            unlink($file_name);
            $data['shop_idenfier'] = $_SESSION['shop_identifier'];
            $data['name'] = I('name');
            $data['mobile'] = I('mobile');
            $data['idcard'] = I('idcard');
            $data['signature'] = $res;
            $data['ctime'] =time();
            $res = $lender_db->create($data);
            if ($res) {
                $res = $lender_db->add();
                if ($res) {
                    add_control_log($_SESSION['shop_identifier'],$_SESSION['account'],"添加出借人，名为【".$data['name'].'-'.$data['idcard'].'】','3');
                    MycommonController::ajax('1001', '添加成功');
                } else {
                    MycommonController::ajax('1002', '系统错误，请联系管理员');
                }
            } else {
                MycommonController::ajax('1002', $lender_db->getError());
            }
        }
    }

    /**
     * 删除出借人
     */
    public function del_lender()
    {
        if (!empty($_POST)) {
            $lender_db = D('Lender');
            $idcard = I('idcard');
            $res = $lender_db->del_lender($idcard);
            if ($res === true) {
                add_control_log($_SESSION['shop_identifier'],$_SESSION['account'],"删除出借人【".$idcard.'】','3');
                MycommonController::ajax('1001', '删除成功');
            } else {
                MycommonController::ajax('1002', $res);
            }
        }
    }

    /**
     * 凭证统计
     */
    public function voucher_statistics()
    {
        $certificate_db=D('certificate');
        $certificate_period_db=M('certificate_period','','XYC');
        $shop_all_data_statistics_db=M('shop_all_data_statistics','','XYC');
        $time=[strtotime(date('Y-m-d')),strtotime(date('Y-m-d 23:59:59'))];
        $three_time=[strtotime(date('Y-m-d'))-3*24*3600,strtotime(date('Y-m-d'))];
        $shop_identifier=$_SESSION['shop_identifier'];

        $statistics_msg=$shop_all_data_statistics_db->WHERE(['shop_identifier'=>$shop_identifier])->FIND();
        $data['all_no_repay']=$statistics_msg['all_wait_repayment_money'];//全部待收
        $data['all_have_repay']=$statistics_msg['all_borrow_money'];//全部已收
        $data['today_no_repay']=$certificate_db->WHERE(['shop_identifier'=>$shop_identifier,'tear_time'=>'0','repayment_time'=>['between',$time]])->SUM('money');//当天待收
        $data['three_today_no_repay']=$certificate_db->WHERE(['shop_identifier'=>$shop_identifier,'tear_time'=>'0','repayment_time'=>['between',$three_time]])->SUM('money');//三天内未回款

        //近期七天数据统计
        $redis=MycommonController::mk_redis();
        $choose_time=!empty(I('get.time'))?strtotime(I('get.time')):time();
        $certificate=array();
        $certificate_period=array();
        $date=array();
        $time_s=date('Ymd',$choose_time);
        if(empty($redis->get($time_s.$shop_identifier.RedisPrefixController::CERTIFICATE))){
//有效凭证数
            for ($i = 7; $i >= 0; $i--) {
                //0表示当天
                if ($i == 0) {
                    $date[]=date('Y-m-d',$choose_time);
                    $time = array(strtotime(date('Y-m-d', $choose_time)), strtotime(date('Y-m-d 23:59:59', $choose_time)));
                }else{
                    $date[]=date('Y-m-d',strtotime("-{$i} day",$choose_time));
                    $time = array(strtotime(date('Y-m-d', strtotime("-{$i} day",$choose_time))), strtotime(date('Y-m-d 23:59:59', strtotime("-{$i} day",$choose_time)))); //前一天
                }
                $certificate_where['ctime']=array('between',$time);
                $certificate_where['status']=['in',['2','3','4','5','9']];
                $certificate_where['shop_identifier']=$_SESSION['shop_identifier'];
                $certificate_s=$certificate_db->WHERE($certificate_where)->COUNT();
                $certificate[]=!empty($certificate_s)?$certificate_s:0;
            }
            //有效展期数
            for ($i = 7; $i >= 0; $i--) {
                //0表示当天
                if ($i == 0) {
                    $time = array(strtotime(date('Y-m-d', $choose_time)), strtotime(date('Y-m-d 23:59:59', $choose_time)));
                }else{
                    $time = array(strtotime(date('Y-m-d', strtotime("-{$i} day",$choose_time))), strtotime(date('Y-m-d 23:59:59', strtotime("-{$i} day",$choose_time)))); //前一天
                }
                $certificate_wheres['ctime']=array('between',$time);
                $certificate_wheres['status']='2';
                $certificate_wheres['shop_idenfier']=$_SESSION['shop_identifier'];
                $certificate_s=$certificate_period_db->WHERE($certificate_wheres)->COUNT();
                $certificate_period[]=!empty($certificate_s)?$certificate_s:0;
            }
            $redis->setex($time_s.$shop_identifier.RedisPrefixController::CERTIFICATE,3600,json_encode($certificate));
            $redis->setex($time_s.$shop_identifier.RedisPrefixController::CERTIFICATE_PERIOD,3600,json_encode($certificate_period));
            $redis->setex($time_s.$shop_identifier.RedisPrefixController::C_DATE,3600,json_encode($date));
        }else{
            $certificate=json_decode($redis->get($time_s.$shop_identifier.RedisPrefixController::CERTIFICATE),true);
            $certificate_period=json_decode($redis->get($time_s.$shop_identifier.RedisPrefixController::CERTIFICATE_PERIOD),true);
            $date=json_decode($redis->get($time_s.$shop_identifier.RedisPrefixController::C_DATE),true);
        }

        $this->assign([
            'data'=>$data,
            'date'=>json_encode($date),
            'certificate'=>json_encode($certificate),
            'certificate_period'=>json_encode($certificate_period)
        ]);
        $this->display();
    }

    /**
     * 支付宝扫码支付接口
     * @param string $orderno 支付订单号
     * @param float $money 支付金额
     * @return \AlipayTradePagePayRequest
     */
    public function certificate_pay($orderno,$money='1'){
        $order_amount=$money;
        $out_trade_no = $orderno;
        $subject='凭证费用';
        $body='支付添加凭证费用';
        Vendor('Alipay.aop.AopClient');
        Vendor('Alipay.aop.request.AlipayTradePagePayRequest');
        //构造参数
        $aop = new \AopClient();
        $aliConfig = C('ALI_CONFIG');
        $aop->gatewayUrl = $aliConfig['gatewayUrl'];
        $aop->appId = $aliConfig['appId'];
        $aop->rsaPrivateKey = $aliConfig['rsaPrivateKey'];
        $aop->apiVersion = '1.0';
        $aop->signType = 'RSA2';
        $aop->postCharset= 'utf-8';
        $aop->format='json';
        $request = new \AlipayTradePagePayRequest ();
        $request->setReturnUrl($aliConfig['returnPcUrl']);
        $request->setNotifyUrl($aliConfig['certificate_notify_url']);
        $request->setBizContent('{"product_code":"FAST_INSTANT_TRADE_PAY","out_trade_no":"'.$out_trade_no.'","subject":"'.$subject.'","total_amount":"'.$order_amount.'","body":"'.$body.'"}');
        //请求
        $result = $aop->pageExecute ($request);
        return $result;
    }
}